﻿using Edu.Presentation;
using MainApp.Utils;
using System.Windows;

namespace MainApp
{
    /// <summary>
    /// IconWindow.xaml 的交互逻辑
    /// </summary>
    public partial class IconWindow : Window
    {
        public bool ForceClose { get; set; }
        public IconWindow()
        {
            InitializeComponent();
            Loaded += IconWindow_Loaded;
        }

        private void IconWindow_Loaded(object sender, RoutedEventArgs e)
        {
            var renderSize = RenderSize;
            var screenSize = PresentationHelper.GetWPFScreenSize();
            Left = screenSize.Width - renderSize.Width;
            Top = (screenSize.Height - renderSize.Height) / 2;
            Closing += IconWindow_Closing;
        }

        private void IconWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            e.Cancel = !ForceClose;
        }

        private void Thumb_DragDelta(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e)
        {
            Left += e.HorizontalChange;
            Top += e.VerticalChange;
        }

        private void Thumb_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            Tools.ShowSettingsWindow();
        }
    }
}
